package com.tywj.lib.net.retrofit

import com.tywj.lib.net.retrofit.callback.BaseCallback
import com.tywj.lib.net.retrofit.request.GetRequest
import com.tywj.lib.net.retrofit.request.PostRequest
import io.reactivex.disposables.Disposable

/**
 * <pre>
 *     author : June Yang
 *     time   : 2020/5/7
 *     desc   : 网络请求工具类
 *     version: 1.0.0
 * </pre>
 */
object HttpUtil {
    internal lateinit var httpConfig: HttpConfig

    fun initHttpConfig(config: HttpConfig) {
        httpConfig = config
    }

    fun get(url: String): GetRequest = GetRequest(url)

    fun post(url: String, isJson: Boolean = false) = PostRequest(url,isJson)

    fun <T> retryRequest(baseCallback: BaseCallback<T>): Disposable? {
        return baseCallback.request.execute(baseCallback)
    }

    //TODO: put delete

}